package com.hy.mapper;

import com.hy.pojo.Draft;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DraftMapper {
    @Insert("INSERT INTO draft (content, title, user_id, status, create_time, update_time) " +
           "VALUES (#{content}, #{title}, #{userId}, #{status}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Draft draft);
    @Delete("DELETE FROM draft WHERE id = #{id}")
    void deleteById(Long id);
    @Update("UPDATE draft SET content = #{content}, title = #{title}, " +
            "status = #{status}, update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(Draft draft);
    @Select("SELECT * FROM draft WHERE id = #{id}")
    List<Draft> selectById(Long id);
    @Select("SELECT * FROM draft WHERE user_id = #{userId}")
    List<Draft> selectByUserId(Long userId);

}
